#ifndef XPMDOC_DAL_DOC_JSON_ACCESS_H
#define XPMDOC_DAL_DOC_JSON_ACCESS_H
#include <string>
#include "model/XpmTermDoc.h"
#include "libjson.h"
#include "DocAccess.h"


namespace conex {
	class TermFactory;
	class TermControl;
}

class JSONNode;
namespace xpm {
	using namespace std;
	
	class DocJsonAccess : public DocAccess {
	public:
		DocJsonAccess(conex::TermFactory* termFactory): DocAccess(termFactory) {Init();}
		void Init();
		virtual ~DocJsonAccess();
		virtual int Load(XpmTermDoc& voc);
		virtual int Load(XpmTermDoc& voc, string signs);
		virtual bool Save(XpmTermDoc& voc, string& syntax);
		virtual string WriteTarget(XpmTermDoc& voc, string& syntax);
		void SetFilename(const char* filename);
		string GetFilename();
		bool SaveAs(XpmTermDoc& voc, const char* filename, string& syntax);
		bool SaveAsPureJson(XpmTermDoc& voc, const char* filename, string& syntax);
		int ParseWithJson(const char* filename, XpmTermDoc& doc);
		//parse the xml document with schema, return the true of false
		//serilizae xml 
		//parses
		void ParseSignsBlocks(JSONNode n, XpmTermDoc& voc);
		void ParseSigns(JSONNode n, XpmTermBlock* block);
	private:
	};

}
#endif